Skip to content

OAuth Github 기능 구현하기#158

Open
ESJung95 wants to merge 7 commits intodevelopfrom
feat/oauth-github
Open

OAuth Github 기능 구현하기#158
ESJung95 wants to merge 7 commits intodevelopfrom
feat/oauth-github

Conversation

@ESJung95
Copy link
Copy Markdown
Owner

@ESJung95 ESJung95 commented Aug 16, 2024

변경사항

AS-IS

  • 기존에는 일반 로그인 방식만 지원
  • GitHub OAuth 인증 기능이 없음

TO-BE

  • GitHub OAuth를 통한 로그인 기능 추가
  • SecurityConfig에 OAuth2 관련 설정 추가
  • GithubOAuthService 클래스 구현으로 GitHub API를 통한 사용자 정보 획득
  • OAuth2GithubSuccessHandler 구현으로 인증 성공 시 자동 사용자 등록 및 JWT 토큰 발급
  • 신규 사용자의 경우 임시 비밀번호 생성 및 암호화 처리

테스트

  • API 테스트

추가 설명

  • 현재 구현은 GitHub OAuth만을 지원합니다.
  • 보안 강화를 위해 임시 비밀번호는 랜덤 클래스로 생성되고, 암호화까지 진행합니다.
  • OAuth 인증 후 /common/job-postings?page=1(메인 페이지)로 리다이렉션되도록 설정되어 있습니다.

- OAuth2 기능 구현 준비
- SecurityConfig에 OAuth2 로그인 설정 추가
- OAuth2 관련 엔드포인트에 대한 접근 권한 설정
- GithubOAuthService 클래스 생성
- OAuth2User loadUser 메서드 구현
- GitHub API를 통한 사용자 이메일 및 이름 정보 가져오기
- 사용자 정보를 OAuth2User 형태로 변환하는 로직 추가
- OAuth2GithubSuccessHandler 클래스 생성
- 인증 성공 시 사용자 정보 처리 및 JWT 토큰 생성
- 신규 사용자 자동 등록 기능 구현
- 인증 후 리다이렉션 처리
- 임시 비밀번호 생성 및 암호화 로직 추가
Copy link
Copy Markdown
Collaborator

@IM-GYURI IM-GYURI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

public class PasswordEncoderConfig {

@Bean
public PasswordEncoder passwordEncoder() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 은선님께서 말씀해주신 것처럼 PasswordEncoder를 Config로 따로 뺐더니 순환 참조 문제가 해결되었습니다! 감사해요 ㅎㅎ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants